<?php
ob_start();
session_start();

require_once("../configuration.php");
require_once("../includes/db/constant.php");
require_once("../includes/db/dbsetup.php");
define(TEMPLATE_NAME,"admin");
require_once("../includes/MySmarty.class.php");
require_once('../localization.php');
require_once('../localization_func.php');


include("bean/product.class.php");
define("UPLOAD_DIR_FROM_ADMIN", '..'  . UPLOAD_DIR_STORE);
$smarty->assign("TEMPLATE_NAME_PATH", TEMPLATE_NAME);
//If Ajax script want to check some value
//use this interface
if(isset($_GET['interface']))
{
	include("includes/interface.php");
	ob_end_flush();
	return;
}
?>

<?php
	
	//check login status, if user not login the code below will not execute
	require_once("mustlogin.php");
	
	$smarty->assign_by_ref("LANGMETA", $langmeta);
	
	$str1 = sprintf(_("Welcome %s"), $_SESSION['u_name']);
	$str2 = _("Logout");
	
	$str3 = sprintf("%s <a href='./logout.php' class='link'>%s</a>", $str1, $str2);
	
	$smarty->assign("WELCOME_MSG", $str3);
	
	$option = "";
	if(isset($_GET["mod"]))
		$option = $_GET["mod"];
	
	if($option=="")
	{
		$option = "dashboard";
	}
	
	/**
	 * Show the main content
	 */
	if (file_exists("classes/$option.class.php"))
	{
		include_once("classes/$option.class.php");
	
		// we render html depend on parameter
		if($option != "")
		{
			//we use @ sign to ignore error and do not show any thing
			@($$option = new $option($db, $smarty));
			
			$$option->process();
		}
	}
	if($_GET['mod'] == "partnerman")
	{
		$_SESSION['mod'] = "partnerman";
		
	}
	else if($_GET['mod'] == "manage" && $_GET['sub1'] == "news")
	{
		$_SESSION['mod'] = "news";
		
	}
	else if($_GET['mod'] == "downloadman")
	{
		$_SESSION['mod'] = "downloadman";
		
	}
	else
	{
		unset($_SESSION['mod']);
	}
	
//echo UPLOAD_DIR_PRODUCTS;
ob_end_flush();
?>